package com.framework.yhbapi.controller;

import com.framework.exception.util.RespResult;
import com.framework.service.yhbservice.YhbCreditCardService;
import com.framework.yhbEntity.user.YhbCreditCard;
import com.framework.yhbEntity.view.CusTranView;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 功能描述: 信用卡控制器
 *
 * @author ck
 * @date 2018/11/9 15:54
 */
@RestController
@Api(value="信用卡模块",tags={"信用卡模块"})
@RequestMapping(value = "yhbCard")
public class YhbCreditCardController {

	@Autowired
	private YhbCreditCardService yhbCreditCardService;

	/**
	 * 查询是否可以申请信用卡
	 * @param userId
	 * @param bankType
	 * @param phone
	 * @return
	 */
	@GetMapping("notValidate/queryIsCard")
	@ApiOperation("查询是否可以申请信用卡")
	public RespResult queryIsCard(String userId,Integer bankType,String phone) {
		boolean isCardRepeat = yhbCreditCardService.queryIsCardRepeat(userId,bankType,phone);
		return RespResult.ok().put("isCardRepeat",isCardRepeat);
	}

	/**
	 * 提交信用卡
	 * @return
	 */
	@PostMapping("notValidate/insertCard")
	@ApiOperation("提交信用卡")
	@ApiImplicitParam(name="yhbCreditCard",value="信用卡申请对象",dataType="com.framework.yhbEntity.user.YhbCreditCard", paramType = "query" ,required = false)
	public RespResult insertCard(YhbCreditCard yhbCreditCard) {
		yhbCreditCardService.insertCard(yhbCreditCard);
		return RespResult.ok();
	}

	/**
	 * 获取推荐办卡列表
	 * @param token
	 * @param type
	 * @return
	 */
	@PostMapping("user/getCreditCardList")
	@ApiOperation("获取推荐办卡列表")
	@ApiImplicitParams({
			@ApiImplicitParam(name="token",value="信用卡申请对象",dataType="string", paramType = "query" ,required = true),
			@ApiImplicitParam(name="type",value="审核情况 0：新进件 1：通过 2：审核中 3：审核失败",dataType="integer", paramType = "query" ,required = true),
			@ApiImplicitParam(name="pageNo",value="页数",dataType="integer", paramType = "query" ,required = true)
	})
	public RespResult getCreditList(String token,Integer type,Integer pageNo){
		List<CusTranView> list=yhbCreditCardService.getCreditCardList(token,type,pageNo);
		return RespResult.ok().put("list",list);
	}


}
